package com.voip.Invite;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created by RXJ on 2018/1/25.
 */
public class text {
    public static void main(String[] args) throws UnknownHostException {
        int pid =0;
        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        String name = runtime.getName();
        System.out.println("当前进程的标识为："+name);
        int index = name.indexOf("@");
        if (index != -1) {
            pid = Integer.parseInt(name.substring(0, index));
            System.out.println("当前进程的PID为："+pid);
        }
        int port = pid;
        String ip = InetAddress.getLocalHost().getHostAddress();

        SipHandler sipHandler = new SipHandler(ip,port);
        sipHandler.setUsername("814");
        sipHandler.setPassword("123456");
        sipHandler.setRegistrarHost("192.168.1.218"); //注册域名
        sipHandler.setRegistrarPort(5060);
        sipHandler.setRegistrarDomain("192.168.1.218"); //注册域名
        sipHandler.init();
    }
}
